package common.fengkai.filepost.common.mq;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

/**
 * @author Fengkai
 * @creat 2021/12/28
 */
public class SyncProducer {
    //同步生产者
       public static void main(String[] args) throws Exception {
           DefaultMQProducer pg = new DefaultMQProducer("pg");
           pg.setNamesrvAddr("192.168.157.130:9876");
           pg.start();

           for (int i = 0; i <10 ; i++) {
               byte[] body = ("HI," + i).getBytes();
               Message message = new Message("someTopic", "someTag", body);
               SendResult sendResult = pg.send(message);
               System.out.println(sendResult);
           }

       }
}
